package com.ruoyi.technician.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.technician.domain.TechnicianType;
import com.ruoyi.technician.service.ITechnicianTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 技师类型Controller
 * 
 * @author ruoyi
 * @date 2025-04-07
 */
@RestController
@RequestMapping("/technicianType/technicianType")
public class TechnicianTypeController extends BaseController
{
    @Autowired
    private ITechnicianTypeService technicianTypeService;

    /**
     * 查询技师类型列表
     */
    @PreAuthorize("@ss.hasPermi('technicianType:technicianType:list')")
    @GetMapping("/list")
    public TableDataInfo list(TechnicianType technicianType)
    {
        startPage();
        List<TechnicianType> list = technicianTypeService.selectTechnicianTypeList(technicianType);
        return getDataTable(list);
    }

    /**
     * 导出技师类型列表
     */
    @PreAuthorize("@ss.hasPermi('technicianType:technicianType:export')")
    @Log(title = "技师类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TechnicianType technicianType)
    {
        List<TechnicianType> list = technicianTypeService.selectTechnicianTypeList(technicianType);
        ExcelUtil<TechnicianType> util = new ExcelUtil<TechnicianType>(TechnicianType.class);
        util.exportExcel(response, list, "技师类型数据");
    }

    /**
     * 获取技师类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('technicianType:technicianType:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(technicianTypeService.selectTechnicianTypeById(id));
    }

    /**
     * 新增技师类型
     */
    @PreAuthorize("@ss.hasPermi('technicianType:technicianType:add')")
    @Log(title = "技师类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TechnicianType technicianType)
    {
        return toAjax(technicianTypeService.insertTechnicianType(technicianType));
    }

    /**
     * 修改技师类型
     */
    @PreAuthorize("@ss.hasPermi('technicianType:technicianType:edit')")
    @Log(title = "技师类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TechnicianType technicianType)
    {
        return toAjax(technicianTypeService.updateTechnicianType(technicianType));
    }

    /**
     * 删除技师类型
     */
    @PreAuthorize("@ss.hasPermi('technicianType:technicianType:remove')")
    @Log(title = "技师类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(technicianTypeService.deleteTechnicianTypeByIds(ids));
    }
}
